package org.addy.simpletable.column.renderer;

import javax.swing.table.DefaultTableCellRenderer;
import java.io.File;

/**
 * @ClassName: FileTableCellRenderer
 * @Description:
 * @Author: yanlc
 * @Date: 2024-02-23
 */
public class FileTableCellRenderer extends DefaultTableCellRenderer {

    @Override
    protected void setValue(Object value) {
        if (value != null) {
            String v = (String) value;
            File file = new File(v);
            if (file.exists()) {
                setText(file.getName());
            } else {
                setText(v);
            }
        } else {
            setText("");
        }
    }

}
